
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>iprPy.input package &#8212; iprPy 0.10.2 documentation</title>
    <link rel="stylesheet" href="../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
    <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="iprPy.record package" href="record.html" />
    <link rel="prev" title="iprPy.database package" href="database.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="record.html" title="iprPy.record package"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="database.html" title="iprPy.database package"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">iprPy 0.10.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">iprPy package</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="iprpy-input-package">
<h1>iprPy.input package<a class="headerlink" href="#iprpy-input-package" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-iprPy.input">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-iprPy.input" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="iprPy.input.boolean">
<code class="sig-name descname">boolean</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.input.boolean" title="Permalink to this definition">¶</a></dt>
<dd><p>Allows conversion of strings to Booleans.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>value</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a>) – If str, then ‘true’ and ‘t’ become True and ‘false’ and ‘f’ become
false. If bool, simply return the value.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Equivalent bool of value.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)">bool</a></p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><strong>ValueError</strong></a> – If value is unrecognized.</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.input.parse">
<code class="sig-name descname">parse</code><span class="sig-paren">(</span><em class="sig-param">inscript</em>, <em class="sig-param">singularkeys=[]</em>, <em class="sig-param">allsingular=False</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.input.parse" title="Permalink to this definition">¶</a></dt>
<dd><p>Parses an input file and returns a dictionary of parameter terms.</p>
<p>These are the parsing rules:</p>
<ul class="simple">
<li><p>The first word in a line is taken as the key name of the parameter.</p></li>
<li><p>All other words are joined together into a single string value for the
parameter.</p></li>
<li><p>Words that start with # indicate comments with that word and all words
to the right of it in the same line being ignored.</p></li>
<li><p>Any lines with less than two non-comment terms are ignored. In other
words, blank lines and lines with keys but not values are skipped over.</p></li>
<li><p>Multiple values can be assigned to the same term by repeating the key
name on a different line.</p></li>
<li><p>The keyword arguments can be used to issue an error if multiple values
are trying to be assigned to terms that should only have a single
values.</p></li>
</ul>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>inscript</strong> (<em>string</em><em> or </em><em>file-like-object</em>) – The file, path to file, or contents of the input script to parse.</p></li>
<li><p><strong>singularkeys</strong> (<em>list of str</em><em>, </em><em>optional</em>) – List of term keys that should not have multiple values.</p></li>
<li><p><strong>allsingular</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – Indicates if all term keys should be singular (Default is False).</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>params</strong> – Dictionary of parsed input key-value pairs</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)">dict</a></p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><strong>ValueError</strong></a> – If both singularkeys and allsingular are given, or if multiple values
    found for a singular key.</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.input.termtodict">
<code class="sig-name descname">termtodict</code><span class="sig-paren">(</span><em class="sig-param">term</em>, <em class="sig-param">keys</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.input.termtodict" title="Permalink to this definition">¶</a></dt>
<dd><p>Takes a str term and parses it into a dictionary of key-value pairs
based on the supplied key list.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>term</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a><em>, </em><em>unicode</em>) – The str term to parse.</p></li>
<li><p><strong>keys</strong> (<em>list of str</em>) – The list of keys to parse by.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Dictionary of parsed key-value terms.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)">dict</a></p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><strong>ValueError</strong></a> – If any key appears multiple times or the first word in term does not
    match a key.</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.input.value">
<code class="sig-name descname">value</code><span class="sig-paren">(</span><em class="sig-param">input_dict</em>, <em class="sig-param">key</em>, <em class="sig-param">default_unit=None</em>, <em class="sig-param">default_term=None</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.input.value" title="Permalink to this definition">¶</a></dt>
<dd><p>Interprets a calculation parameter by converting it from a string to a
float in working units.</p>
<p>The parameter being converted is a str with one of two formats:
- ‘&lt;number&gt;’
- ‘&lt;number&gt; &lt;unit&gt;’</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>input_dict</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)"><em>dict</em></a>) – Dictionary containing input parameter key-value pairs.</p></li>
<li><p><strong>key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a>) – The key of input_dict to evaluate.</p></li>
<li><p><strong>default_unit</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a><em>, </em><em>optional</em>) – Default unit to use if not specified in the parameter value.  If not
given, then no unit conversion will be done on unitless parameter
values.</p></li>
<li><p><strong>default_term</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a><em>, </em><em>optional</em>) – Default str parameter value to use if key not in input_dict.  Can be
specified as ‘&lt;value&gt; &lt;unit&gt;’ to ensure that the default value is
always the same regardless of the working units or default_unit.  If
not given, then key must be in input_dict.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The interpreted value of the input parameter’s str value in the
working units.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)">float</a></p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.input.buildcombos">
<code class="sig-name descname">buildcombos</code><span class="sig-paren">(</span><em class="sig-param">style</em>, <em class="sig-param">database</em>, <em class="sig-param">keys</em>, <em class="sig-param">content_dict=None</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.input.buildcombos" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper function for the modular buildcombos styles</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>style</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a>) – The buildcombos style to use</p></li>
<li><p><strong>database</strong> (<a class="reference internal" href="database.html#iprPy.database.Database" title="iprPy.database.Database"><em>iprPy.database.Database</em></a>) – The database to use in building combos</p></li>
<li><p><strong>keys</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><em>list</em></a>) – The calculation multikey set to build combos for</p></li>
<li><p><strong>content_dict</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)"><em>dict</em></a><em>, </em><em>optional</em>) – Contains loaded file content.  If not given, an empty
dict will be created</p></li>
<li><p><strong>kwargs</strong> (<em>any</em>) – Additional keyword arguments will be used to limit which records from
the database are used in building combos values.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>inputs</strong> (<em>dict</em>) – Contains the values generated for each key</p></li>
<li><p><strong>content_dict</strong> (<em>dict</em>) – Contains loaded file content</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.input.subset">
<code class="sig-name descname">subset</code><span class="sig-paren">(</span><em class="sig-param">style</em>, <em class="sig-param">prefix=''</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.input.subset" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper function for the modular subset styles</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>style</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a>) – The subset style to access</p></li>
<li><p><strong>prefix</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a><em>, </em><em>optional</em>) – The prefix to add to all keys of the subset</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>iprPy.input.subset_classes.Subset subclass</p>
</dd>
</dl>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">iprPy.input package</a><ul>
<li><a class="reference internal" href="#module-iprPy.input">Module contents</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="database.html"
                        title="previous chapter">iprPy.database package</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="record.html"
                        title="next chapter">iprPy.record package</a></p>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="record.html" title="iprPy.record package"
             >next</a> |</li>
        <li class="right" >
          <a href="database.html" title="iprPy.database package"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">iprPy 0.10.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >iprPy package</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.1.2.
    </div>
  </body>
</html>